* Random coder simulation with continuous beauty

quietly do "Scholz-Sicinski data prep.do"

foreach var of newlist pop exp expsq mar tenure union outwis ind ieduc educ beauten iqten edten {
qui gen `var'=.
}
foreach var of varlist outwis pop exp expsq mar tenure union outwis ind ieduc {
qui replace `var'=`var'74     
}

log using "Scholz-Sicinski random coder simulation.log", replace

*Premium or penalty with one random coder
program randreg74, rclass
version 12.0

gen whichscore=12*uniform()
gen randbeauty=.
foreach score of numlist 1/12 {
replace randbeauty=score`score' if whichscore<=`score'
replace whichscore=. if whichscore<=`score'
}

qui egen zrandbeau=std(randbeauty)

regress lwage74 zrandbeau iqscore fathed mothed fathproex pinc57 farmbg i.ipop57 sibsnum  ///
 fullhh momemployed  hssize milty pop exp expsq mar tenure union outwis i.ind i.ieduc ///
 ivocat  if female==0 & zerowage74==0 & selfemp74==0

drop whichscore zrandbeau randbeauty 

end

simul _b _se ,reps(10000) :randreg74

gen trandb74=_b_zrandbeau/_se_zrandbeau

gen starrandb74=0
replace starrandb74=1 if trandb74>=1.645

gen twostarrandb74=0
replace twostarrandb74=1 if trandb74>=1.96
tab1 starrandb74 twostarrandb74

sum _b_zrandbeau,d

log c
